package com.oss.service.support;

import java.io.Serializable;
import java.lang.reflect.Method;

import org.aopalliance.intercept.MethodInvocation;
import org.oss.client.dto.OssSecurityRequest;
import org.springframework.cache.interceptor.KeyGenerator;

import com.oss.vo.UserAuth;

public class OssKeyGenerator implements  KeyGenerator  {

	public Serializable generateKey(MethodInvocation methodInvocation) {
		String product = String.format("product_of_%s", methodInvocation.getArguments()[0]);
		return product;
	}


	@Override
	public Object generate(Object target, Method method, Object... params) {
		if(params.length > 1){
			UserAuth auth = (UserAuth) params[1];
			StringBuffer key  = new StringBuffer();
			
			key.append(auth.getId()+"/"+auth.getAccConfig().getId());
			System.out.println(method.getName()+"==========="+key.toString());
			return key.toString();
		}else{
			System.out.println(method.getName()+"----------"+params[0]);
			return params[0];
		}
		
		
	}

}
